﻿using UnityEngine;
using System.Collections;
using Game.Scripts.Managers;

namespace Assets.Game.scripts.ui.models {

    public class BuildingPrototypeItemRendererModel : MonoBehaviour {

        public BuildingPrototype prototype;

        private Resource wood = null;
        private Resource stone = null;

        public void Start() {
            Resource[] costs = this.prototype.GetListCost(1);
            if(costs != null)
            foreach (Resource resource in costs) {
                if (resource.type == ResourceEnum.Stone) {
                    this.stone = resource;
                }else if(resource.type == ResourceEnum.Wood )
                {
                    this.wood = resource;
                }
            }
        }


        public string prototypeName {
            get {
                return this.prototype.name;
            }
        }

        public UIAtlas prototypeAtlas {
            get {
                return this.prototype.atlasName;
            }
        }

        public string prototypeSpriteName {
            get {
                return this.prototype.iconName;
            }
        }

        public int woodCost {
            get {
                if (this.wood != null)
                {
                    return (int)this.wood.amount;
                }
                else
                    return 9999;
            }
        }

        public int stoneCost {
            get {
                if (this.stone != null) 
                    return (int)this.stone.amount;
                else
                    return 9999;
            }
        }
    }

}